package ThreadDemo;

import static java.lang.Thread.sleep;

public class ThreadDemo10 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(){
            @Override
            public void run() {
                while(true){
                    try {
                        sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("我是新线程");
                }

            }
        };
        t.start();
        while(true){
            System.out.println("我是主线程");
            sleep(500);
        }

    }
}
